package org.example.ssh

import net.schmizz.sshj.SSHClient
import org.example.ssh.base.SSH
import org.example.ssh.base.SshCtx
import org.example.ssh.base.executeCmdPrint
import org.example.ssh.base.uploadDirectoryRecursive

suspend fun main() {
    val list = SSH.getGroup("dev_monitor-HK-2001")
    SSH.execF(list) {
        DeployMonitor().deploy(it)
    }
}

/**

https://grafana.com/grafana/dashboards/

 */
class DeployMonitor {

    suspend fun deploy(sshCtx: SshCtx) {
        val sftp = sshCtx.cli.newSFTPClient()
        uploadDirectoryRecursive(sftp, "./配置/monitor", "/home")
        executeCmdPrint(sshCtx.cli, "cd /home/monitor && docker-compose -f docker-compose.yml down")
        executeCmdPrint(sshCtx.cli, "cd /home/monitor && docker-compose -f docker-compose.yml up -d")
//        executeCmdPrint(sshCtx.cli, "docker ps")
//        executeCmdPrint(sshCtx.cli, "cd /home/monitor && docker-compose logs alertmanager-feishu ")

    }
}










